import 'package:flutter/material.dart';
import '../local/pages/context_header.dart';

abstract class Demo extends Widget {
  Demo(this.title);
 final String title;
}

class IconSource extends StatelessWidget {
  final String title;
  final String source;
  IconSource(this.title,this.source);
  @override
  Widget build(BuildContext context) {
    return IconButton(
        icon: Icon(Icons.subject),
        onPressed: () {
          App.navigateTo(context, "/source?title=${this.title}&source=${this.source}");
        });
  }
}

class ResourceWidget extends StatelessWidget {
  final String source;
  final String title;
  ResourceWidget(this.title, this.source);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
      ),
      body: Container(
          padding: EdgeInsets.all(8.0),
          color: Colors.black12,
          child: SingleChildScrollView(
            child: Text(this.source),
          )),
    );
  }
}

String sourceDemo01 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import '../local/pages/context_header.dart';
class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }

  @override
  String title;

}

class HomePage extends StatefulWidget {
   String title;
  HomePage({key, this.title});
  @override
  State<StatefulWidget> createState() => new _HomePageState(title: this.title);
}

class _HomePageState extends State<HomePage> with RouteAware {
  int count = 0;
  String title;
  _HomePageState({key, this.title});
  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    App.routeObserver.subscribe(this, ModalRoute.of(context));
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
      title: Text(this.title),
        actions: <Widget>[
          IconButton(icon: Icon(Icons.message), onPressed: (){
            App.navigateTo(context, "/source?source=sfad&title=${this.title}");
          })
        ],
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text("您已经点击按钮的次数", style: Theme.of(context).textTheme.title),
            Text(
              "$count",
              style: Theme.of(context).textTheme.display1,
            )
          ],
        ),
      ),
      floatingActionButton: Row(
        mainAxisAlignment: MainAxisAlignment.end,
        crossAxisAlignment: CrossAxisAlignment.end,
        children: <Widget>[
          Align(
            widthFactor: 2,
            alignment: FractionalOffset.bottomRight,
            child: FloatingActionButton(
              heroTag: 'btn1',
              onPressed: _incrementCounter,
              child: Icon(Icons.add),
            ),
          ),
          Align(
            widthFactor: 2,
            alignment: FractionalOffset.bottomRight,
            child: FloatingActionButton(
              heroTag: "btn2",
              onPressed: _decrementCounter,
              child: Icon(Icons.remove),
            ),
          )
        ],
      ),
    );
  }

  void _incrementCounter() {
    setState(() {
      count++;
    });
  }

  void _decrementCounter() {
    setState(() {
      count--;
    });
  }
}


''';
String sourceDemo02 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'package:wonders_one_demo/local/pages/index.dart';
import 'ui_demo_listView.dart';
//void main() => runApp(new MyFirstApp());

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(
      title: this.title,
    );
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: new AppBar(
          title: Text(this.title),
          leading: IconButton(
              icon: Icon(Icons.chevron_left),
              onPressed: () {
                Navigator.pushAndRemoveUntil(context,
                    new MaterialPageRoute(builder: (BuildContext context) {
                  return IndexPage();
                }), (route) => route == null);
              }),
          actions: <Widget>[
            IconSource("list view"),
          ],
        ),
        body: ListViewDemo());
  }
}

import 'package:flutter/material.dart';
import 'data_source/data.dart';
import 'ui_demo_listView_detail.dart';
import '../wonders/framework.dart';

class ListViewDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _ListViewState();
  }
}

class _ListViewState extends State<ListViewDemo> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
//    return ListView.builder(
//        itemCount: imagesList.length, itemBuilder: _listItemBuilder);
    return ListLayout(itemCount: imagesList2.length, builder: _listItemBuilder);
  }

  Widget _listItemBuilder(BuildContext context, int index) {
    return Container(
      color: Colors.white,
      margin: EdgeInsets.fromLTRB(5, 10, 5, 0),
      padding: EdgeInsets.all(10.0),
      child: Stack(
        children: <Widget>[
          Column(
            children: <Widget>[
              //Image.asset("assets/images/4.jpg"),
              AspectRatio(
                  aspectRatio: 16 / 9,
                  child: Image.network(
                    imagesList2[index].url,
                    fit: BoxFit.cover,
                  )),
              SizedBox(
                height: 10.0,
              ),
              Text(
                imagesList2[index].name,
                style: TextStyle(fontSize: 14.0),
              ),
              Text(
                imagesList2[index].desc,
                style: TextStyle(color: Colors.black54),
              ),
            ],
          ),
          Positioned.fill(
            child: Material(
              color: Colors.transparent,
              child: InkWell(
                splashColor: Colors.white.withOpacity(0.3),
                highlightColor: Colors.white.withOpacity(0.1),
                onTap: () {
                  debugPrint("InkWell");
                  Navigator.of(context)
                      .push(MaterialPageRoute(builder: (context) {
                    return ListViewDetailDemo(imagesList2[index]);
                  }));
                },
              ),
            ),
          )
        ],
      ),
    );
  }
}

''';
String sourceDemo03 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'package:wonders_one_demo/main.dart';
import 'data_source/data.dart';
import 'ui_demo_drawer.dart';
import 'ui_demo_bottomNavigation.dart';
import 'ui_demo_listView.dart';
//void main() => runApp(new MyFirstApp());

class MyDemo extends StatelessWidget implements Demo {
   MyDemo(this.title);
  @override
   String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 3,
      child: Scaffold(
        appBar: AppBar(
          title: Text(this.title),
          centerTitle: true,
          elevation: 0,
//          leading: IconButton(
//            icon: Icon(Icons.menu),
//            onPressed: () => debugPrint("menu button be pressed"),
//            tooltip: "navigator",
//          ),
          actions: <Widget>[
            IconSource("TabBar","03"),
          ],
          bottom: TabBar(
            unselectedLabelColor: Colors.black38,//未选中图标样式
            indicatorColor: Colors.white,//图标下划线颜色
            indicatorSize: TabBarIndicatorSize.tab,//图标下划线宽度
            indicatorWeight: 2.0,//图标下划线粗细
            tabs: <Widget>[
              Tab(icon: Icon(Icons.local_florist),text: "florist",),
              Tab(icon: Icon(Icons.local_convenience_store),text: "convenience",),
              Tab(icon: Icon(Icons.local_bar),text: "bar",)
            ],
          ),
        ),
        body: TabBarView(
          children: <Widget>[
            //Icon(Icons.local_florist,size: 128.0,color: Colors.black12,),
            ListViewDemo(),
            Icon(Icons.local_convenience_store,size:128.0,color:Colors.black12),
            Icon(Icons.local_bar,size:128.0,color:Colors.black12),
          ],
        ),
        drawer: DrawerDemo(),
        bottomNavigationBar: BottomNavigationDemo(),
      ),
    );
  }
}

import 'package:flutter/material.dart';
class DrawerDemo extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Drawer(
      child: ListView(
        padding: EdgeInsets.all(0.0),
        children: <Widget>[
          UserAccountsDrawerHeader(
            accountName: Text("wondersgroup"),
            accountEmail: Text("mail.wondersgroup.com"),
            currentAccountPicture: Container(
              child: CircleAvatar(
                child: Image.asset("assets/images/4.jpg"),
              ),
              decoration: BoxDecoration(
                  borderRadius:BorderRadius.circular(90.0)
              ),
            ),
            decoration: BoxDecoration(
                color:Colors.blueAccent,
                image: DecorationImage(
                  image: NetworkImage('http://img.lanrentuku.com/img/allimg/1904/15554203773537.jpg'),
                  fit: BoxFit.cover,
                  colorFilter: ColorFilter.mode(
                      Colors.yellow[400].withOpacity(0.6),
                      BlendMode.hardLight
                  ),
                )
            ),
          ),
          ListTile(
            title:Text("message",textAlign: TextAlign.right,),
            trailing: Icon(Icons.message,size: 18,color: Colors.black26),
          ),
          ListTile(
            title:Text("favorite",textAlign: TextAlign.right,),
            trailing: Icon(Icons.favorite,size: 18,color: Colors.black26),
          ),
          ListTile(
            title:Text("settings",textAlign: TextAlign.right,),
            trailing: Icon(Icons.settings,size: 18,color: Colors.black26,),
          ),
          ListTile(
            title:Text("close",textAlign: TextAlign.right,),
            trailing: Icon(Icons.close,size: 18,color: Colors.black26),
            onTap: ()=>Navigator.pop(context),
          ),
        ],
      ),
    );
  }
}

import 'package:flutter/material.dart';
class BottomNavigationDemo extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _BottomNavigationState();
  }
}
class _BottomNavigationState extends State<BottomNavigationDemo>{
  void _onBottomNavigationBarClick(int index){
    setState(() {
      _defaultIndex=index;
    });
  }
  int _defaultIndex=0;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return BottomNavigationBar(
      type:BottomNavigationBarType.fixed ,
      onTap: _onBottomNavigationBarClick,
      currentIndex: _defaultIndex,
      items: [
        BottomNavigationBarItem(
            title: Text("Explore"),
            icon: Icon(Icons.explore)
        ),
        BottomNavigationBarItem(
            title: Text("History"),
            icon: Icon(Icons.history)
        ),
        BottomNavigationBarItem(
            title: Text("List"),
            icon: Icon(Icons.list)
        ),
        BottomNavigationBarItem(
            title: Text("My"),
            icon: Icon(Icons.person)
        ),
      ],
    );
  }
}

''';
String sourceDemo04 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 3,
      child: Scaffold(
        appBar: AppBar(
          title: Text(this.title),
          centerTitle: true,
          elevation: 0,
          actions: <Widget>[
            IconSource("BoxDecoration","04"),
          ],
        ),
        body: ListView(
          padding: EdgeInsets.only(left: 10.0),
          children: <Widget>[
            TextDemo(),
            RichTextDemo(),
            BoxDecorationDemo(),
            BoxDecorationDemo2(),
          ],
        ),
      ),
    );
  }
}

class TextDemo extends StatelessWidget {
  TextStyle _textStyle =
      TextStyle(color: Colors.black54, fontWeight: FontWeight.bold);
  final String _author = "李清照";
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      margin: EdgeInsets.only(bottom: 10.0),
      child: Column(
        children: <Widget>[
          ListTile(
            title: Text("Text"),
            contentPadding: EdgeInsets.all(0.0),
          ),
          Text(
            "作者--$_author 生当作人杰，死亦为鬼雄。至今思项羽，不肯过江东。",
            style: _textStyle,
            textAlign: TextAlign.left,
            maxLines: 1,
            overflow: TextOverflow.ellipsis,
          ),
        ],
      ),
    );
  }
}

class RichTextDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      margin: EdgeInsets.only(bottom: 10.0),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          ListTile(
            title: Text("RichText"),
            contentPadding: EdgeInsets.all(0.0),
          ),
          RichText(
            textAlign: TextAlign.center,
            maxLines: 4,
            overflow: TextOverflow.ellipsis,
            text: TextSpan(
                text: "念奴娇赤壁怀古",
                style: TextStyle(
                    color: Colors.black87, fontWeight: FontWeight.bold),
                children: [
                  TextSpan(
                      text: "--苏轼\n",
                      style: TextStyle(fontStyle: FontStyle.italic)),
                  TextSpan(
                      text: "大江东去，浪淘尽，千古风流人物。故垒西边，人道是，三国周郎赤壁。"
                          "乱石穿空，惊涛拍岸，卷起千堆雪。江山如画，一时多少豪杰。"
                          "遥想公瑾当年，小乔初嫁了，雄姿英发。羽扇纶巾，谈笑间，樯橹灰飞烟灭"
                          "故国神游，多情应笑我，早生华发。\n",
                      style: TextStyle(fontWeight: FontWeight.normal)),
                ]),
          )
        ],
      ),
    );
  }
}

class BoxDecorationDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Column(
        children: <Widget>[
          ListTile(
            title: Text("BoxDecoration"),
            contentPadding: EdgeInsets.all(0.0),
          ),
          Container(
            //color: Colors.blueAccent,
            child: Icon(
              Icons.pool,
              color: Colors.white,
              size: 50,
            ),
            width: 100.0,
            height: 100.0,
            decoration: BoxDecoration(
                color: Colors.blueAccent,
//              border: Border(
//                bottom: BorderSide(
//                  width: 2.0,
//                  color: Colors.black26,
//                  style: BorderStyle.solid
//                )
//              )
                border: Border.all(
                    width: 2.0,
                    color: Colors.black26,
                    style: BorderStyle.solid),
                //borderRadius: BorderRadius.circular(24.0),//圆角效果
                shape: BoxShape.circle,//改变box形状，circle不能与borderRadius同时用
//                gradient: RadialGradient(//径向渐变
//                  colors: [
//                    Color.fromRGBO(7, 102, 155, 1),
//                    Color.fromRGBO(3, 28, 128, 1),
//                  ]
//                ),
                gradient: LinearGradient(//线性渐变
                  colors: [
                    Color.fromRGBO(7, 102, 155, 1),
                    Color.fromRGBO(3, 28, 128, 1),
                  ],
                  begin: Alignment.topCenter,
                  end: Alignment.bottomRight
                ),
                boxShadow: <BoxShadow>[ //阴影
                  BoxShadow(
                    offset: Offset(0.0, 12.0), //x,y轴的偏移
                    color: Colors.blueGrey, //阴影颜色
                    blurRadius: 25.0, //模糊程度
                    spreadRadius: 4.0//阴影扩散程度
                  ),
                ]),
          )
        ],
      ),
    );
  }
}

class BoxDecorationDemo2 extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Column(
        children: <Widget>[
          ListTile(title: Text("BoxDecoration（背景）"),contentPadding: EdgeInsets.all(0.0),),
          Container(
            width: 450.0,
            height: 250.0,
            child: Icon(Icons.pool,size: 100,color: Colors.blueAccent,),
            decoration: BoxDecoration(
              image: DecorationImage(
                image: AssetImage("assets/images/3.jpg"),
                fit: BoxFit.fill,
                colorFilter: ColorFilter.mode(
                    Colors.black54,
                    BlendMode.lighten//混合模式
                )
              )
            ),
          ),
        ],
      ),
    );
  }
}
''';
String sourceDemo05 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return  new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 3,
      child: Scaffold(
        appBar: AppBar(
          title: Text(this.title),
          centerTitle: true,
          elevation: 0,
          actions: <Widget>[
            IconSource("LayoutDemo","05"),
          ],
        ),
        body: ListView(
          padding: EdgeInsets.only(left: 10.0,right: 10.0),
          children: <Widget>[
            RowColumnDemo(),
            SizedBoxDemo(),
            AspectRatioDemo(),
            ConstraineDemo(),
          ],
        ),
      ),
    );
  }
}

class IconBadge extends StatelessWidget {
  final IconData icon;
  final double size;
  IconBadge(this.icon, this.size);
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      width: size + 60,
      height: size + 60,
      decoration: BoxDecoration(
          color: Colors.blueAccent,
          borderRadius: BorderRadius.only(topLeft: Radius.circular(9.0))),
      child: Icon(
        icon,
        size: size,
      ),
    );
  }
}

class RowColumnDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      padding: EdgeInsets.all(5.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        //crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          IconBadge(Icons.pool, 20.0),
          IconBadge(Icons.delete_sweep, 40.0),
          IconBadge(Icons.pages, 20.0),
        ],
      ),
    );
  }
}

class SizedBoxDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      padding: EdgeInsets.all(5.0),
      height: 100.0,
      child: Stack(
        children: <Widget>[
          Container(
            alignment: Alignment(-1.0, 0.0),
            child: Icon(
              Icons.person,
              size: 40,
              color: Colors.white,
            ),
            decoration: BoxDecoration(
                color: Colors.blueAccent, borderRadius: BorderRadius.circular(8.0)),
          ),
          Container(
            child: Icon(Icons.pool,color: Colors.white,size: 35,),
            margin: EdgeInsets.only(left: 50.0,top: 35.0),
          ),
          Positioned(
            child: Icon(Icons.ac_unit,color: Colors.white,),
            top: 10.0,
            right: 10.0,
          ),
          Positioned(
            child: Icon(Icons.ac_unit,size:16.0,color: Colors.white,),
            top: 25.0,
            right: 45.0,
          )
        ],
      )
    );
  }
}
class AspectRatioDemo extends StatelessWidget{
  /**
   * 固定比例的box
   */
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: AspectRatio(
          aspectRatio: 4.0/2.0,//宽高比
          child: Container(
            width: 10.0,
            color: Colors.blueAccent,
            child: Icon(Icons.history,size: 45.0,),
          ),
      ),
    );
  }
}
class ConstraineDemo extends StatelessWidget{
  /**
   * 带限制的box
   */
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return ConstrainedBox(
      constraints: BoxConstraints(
        minHeight: 100.0,
        maxWidth: 200.0
      ),
      child: Container(
        margin: EdgeInsets.only(top: 10.0),
          child: Container(
            width: 10.0,
            color: Colors.blueAccent,
            child: Icon(Icons.poll,size: 45.0,color: Colors.white,),
          ),
      ),
    );
  }
}

''';
String sourceDemo06 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'data_source/data.dart';
import 'data_source/post.dart';
import '../wonders/framework.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 2,
      child: Scaffold(
        appBar: AppBar(
          title: Text(this.title),
          centerTitle: true,
          elevation: 0,
          actions: <Widget>[
            IconSource("PageView,GridView","06"),
          ],
          bottom: TabBar(
            tabs: <Widget>[
              Tab(
                icon: Icon(Icons.pages),
                text: "PageView",
              ),
              Tab(
                icon: Icon(Icons.grid_on),
                text: "GridView",
              ),
            ],
          ),
        ),
        body: TabBarView(
          children: <Widget>[
            PageViewDemo(),
            GridViewDemo(),
          ],
        ),
      ),
    );
  }
}

class PageViewDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    //return PageViewStaticDemo();
    return PageViewBuilderDemo();
  }
}

class PageViewBuilderDemo extends StatelessWidget {
  Widget _itemBuilderPageView(BuildContext context, int index) {
    return Stack(
      children: <Widget>[
        SizedBox.expand(
          child: Image.network(
            imagesList2[index].url,
            fit: BoxFit.cover,
          ),
        ),
        Positioned(
          top: 20.0,
          right: 20.0,
          child: Column(
            children: <Widget>[
              Text(
                imagesList2[index].name,
                style: TextStyle(color: Colors.blue, fontSize: 18, shadows: [
                  Shadow(
                      offset: Offset(0.0, 2.0),
                      color: Colors.redAccent,
                      blurRadius: 12.0)
                ]),
              ),
              Text(
                imagesList2[index].desc,
                style: TextStyle(color: Colors.blue, fontSize: 18.0, shadows: [
                  Shadow(
                      offset: Offset(0.0, 2.0),
                      color: Colors.redAccent,
                      blurRadius: 12.0)
                ]),
              ),
            ],
          ),
        )
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
//    return PageView.builder(
//      itemCount: imagesList2.length,
//      itemBuilder: _itemBuilderPageView,
//    );
      return PageLayout(
        builder: _itemBuilderPageView,
        itemCount: imagesList2.length,
      );
  }
}

class PageViewStaticDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return PageLayout(
      reverse: false, //是否是反向滚动
      pageSnapping: true, //页面切换弹出、入
      //scrollDirection: Axis.vertical,//滚动方向
      onPageChanged: (currentPage) => debugPrint("page $currentPage pressed"),
      controller: PageController(
          initialPage: 0, //初始页面
          keepPage: true,
          viewportFraction: 0.85 //屏幕占用比例
          ),
      children: <Widget>[
        Container(
          alignment: Alignment(0.0, 0.0),
          color: Colors.brown[900],
          child: Text(
            "ONE",
            style: TextStyle(fontSize: 40.0, color: Colors.white),
          ),
        ),
        Container(
          alignment: Alignment(0.0, 0.0),
          color: Colors.blueGrey[900],
          child: Text(
            "TWO",
            style: TextStyle(fontSize: 40.0, color: Colors.white),
          ),
        ),
        Container(
          alignment: Alignment(0.0, 0.0),
          color: Colors.cyan[900],
          child: Text(
            "THREE",
            style: TextStyle(fontSize: 40.0, color: Colors.white),
          ),
        )
      ],
    );
  }
}

class GridViewDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    // return GridViewStaticDemo();
    return GridViewBuilderDemo();
  }
}

class GridViewStaticDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
//    return GridView(
//      padding: EdgeInsets.all(5.0),
//      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//        crossAxisCount: 3,
//        crossAxisSpacing: 5.0,
//        mainAxisSpacing: 5.0,
//      ),
//      children: <Widget>[
//        Container(
//          alignment: Alignment(0.0, 0.0),
//          color: Colors.grey,
//          child: Text("ITEM0"),
//        ),
//        Container(
//          alignment: Alignment(0.0, 0.0),
//          color: Colors.grey,
//          child: Text("ITEM1"),
//        ),
//        Container(
//          alignment: Alignment(0.0, 0.0),
//          color: Colors.grey,
//          child: Text("ITEM2"),
//        ),
//        Container(
//          alignment: Alignment(0.0, 0.0),
//          color: Colors.grey,
//          child: Text("ITEM3"),
//        ),
//        Container(
//          alignment: Alignment(0.0, 0.0),
//          color: Colors.grey,
//          child: Text("ITEM4"),
//        ),
//      ],
//    );
    return GridLayout(
      padding: EdgeInsets.all(5.0),
      crossAxisCount: 3,
      mainAxisSpacing: 5.0,
      crossAxisSpacing: 5.0,
      children:<Widget>[
        Container(
          alignment: Alignment(0.0, 0.0),
          color: Colors.grey,
          child: Text("ITEM0"),
        ),
        Container(
          alignment: Alignment(0.0, 0.0),
          color: Colors.grey,
          child: Text("ITEM1"),
        ),
        Container(
          alignment: Alignment(0.0, 0.0),
          color: Colors.grey,
          child: Text("ITEM2"),
        ),
        Container(
          alignment: Alignment(0.0, 0.0),
          color: Colors.grey,
          child: Text("ITEM3"),
        ),
        Container(
          alignment: Alignment(0.0, 0.0),
          color: Colors.grey,
          child: Text("ITEM4"),
        ),
      ],
    );
  }
}

class GridViewBuilderDemo extends StatelessWidget {
  Widget _itemBuilderGridDemo(BuildContext context, int index) {
    return Container(
      child: Image.network(
        posts[index].imageUrl,
        fit: BoxFit.cover,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
//    return GridView.builder(
//        addRepaintBoundaries: true,
//        padding: EdgeInsets.all(4.0),
//        itemCount: posts.length,
//        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//          crossAxisCount: 3,
//          //maxCrossAxisExtent: 100,
//          mainAxisSpacing: 4.0,
//          crossAxisSpacing: 4.0,
//          childAspectRatio: 2 / 3,
//        ),
//        itemBuilder: _itemBuilderGridDemo);
  return GridLayout(
    crossAxisCount: 2,
    childAspectRatio: 3/2,
    mainAxisSpacing: 4.0,
    crossAxisSpacing: 4.0,
    padding: EdgeInsets.all(4.0),
    itemCount: posts.length,
    builder: _itemBuilderGridDemo,
  );
  }
}

''';
String sourceDemo07 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'data_source/post.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 2,
      child: Scaffold(
          appBar: AppBar(
            title: Text(this.title),
            centerTitle: true,
            elevation: 0,
            actions: <Widget>[
              IconSource("SliverGrid、List","07"),
            ],
            bottom: TabBar(
              tabs: <Widget>[
                Tab(
                  icon: Icon(Icons.grid_on),
                  text: "SliverGrid",
                ),
                Tab(
                  icon: Icon(Icons.list),
                  text: "SliverList",
                ),
              ],
            ),
          ),
          body: TabBarView(
            children: <Widget>[
              CustomScrollView(
                slivers: <Widget>[
                  SliverPadding(
                    padding: EdgeInsets.all(4.0),
                    sliver: SliverGridDemo(),
                  ),
                ],
              ),
              CustomScrollView(
                slivers: <Widget>[
                  SliverAppBar(
                    centerTitle: true,
                    //title: Text("SliverAppBar"),
                    floating: true,
                    snap: true, //是否固定在顶部
                    expandedHeight: 150.0,
                    flexibleSpace: FlexibleSpaceBar(
                      title: Text(
                        "Flutter SliverAppBar",
                        style: TextStyle(
                            fontSize: 15.0,
                            letterSpacing: 3.0,
                            color: Colors.white),
                      ),
                      background: Image.network(
                        "https://resources.ninghao.org/images/childhood-in-a-picture.jpg",
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                  SliverSafeArea(
                    sliver: SliverPadding(
                      padding: EdgeInsets.all(4.0),
                      sliver: SliverListDemo(),
                    ),
                  ),
                ],
              ),
            ],
          )),
    );
  }
}

class SliverGridDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return SliverGrid(
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,
        mainAxisSpacing: 4.0,
        crossAxisSpacing: 4.0,
      ),
      delegate: SliverChildBuilderDelegate((context, index) {
        return Container(
          color: Colors.grey,
          child: Stack(
            fit: StackFit.expand,
            children: <Widget>[
              Image.network(
                posts[index].imageUrl,
                fit: BoxFit.cover,
              ),
              Positioned(
                right: 10.0,
                top: 10.0,
                child: Text(
                  posts[index].title,
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ],
          ),
        );
      }, childCount: posts.length),
    );
  }
}

class SliverListDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return SliverList(
      delegate: SliverChildBuilderDelegate((context, index) {
        return Padding(
          padding: EdgeInsets.all(8.0),
          child: Stack(
            children: <Widget>[
              Material(
                borderRadius: BorderRadius.circular(10.0),
                elevation: 14.0,
                child: Container(
                    child: Image.network(
                  posts[index].imageUrl,
                  fit: BoxFit.cover,
                )),
              ),
              Positioned(
                top: 25.0,
                right: 25.0,
                child: Column(
                  children: <Widget>[
                    Text(
                      posts[index].title,
                      style: TextStyle(fontSize: 15.0, color: Colors.white),
                    ),
                    Text(
                      posts[index].author,
                      style: TextStyle(fontSize: 10.0, color: Colors.white),
                    ),
                  ],
                ),
              ),
              Positioned(
                left: 10.0,
                bottom: 10.0,
                right: 60.0,
                child: Text(
                  posts[index].description,
                  style: TextStyle(fontSize: 10.0, color: Colors.white),
                  maxLines: 2,
                  overflow: TextOverflow.ellipsis,
                ),
              )
            ],
          ),
        );
      }, childCount: posts.length),
    );
  }
}

''';
String sourceDemo08 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import '../local/pages/context_header.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        centerTitle: true,
        elevation: 0,
        actions: <Widget>[
          IconSource("MaterialPageRoute","08"),
        ],
      ),
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            FlatButton(
              child: Text("HOME"),
              onPressed: (){
                debugPrint("home pressed");
                Navigator.of(context).push(MaterialPageRoute(
                  builder: (BuildContext context)=>SecondPage("HOME",Icon(Icons.home,size: 128,))
                ));
              },
            ),
            FlatButton(
              child: Text("ABOUT"),
              onPressed: (){
                debugPrint("about pressed");
//                Navigator.of(context).push(MaterialPageRoute(
//                    builder: (BuildContext context)=>SecondPage("ABOUT",Icon(Icons.poll,size: 128,))
//                ));
              App.navigateTo(context, "/about");
              },
            )
          ],
        ),
      ),
    );
  }
}

class SecondPage extends StatelessWidget{
  final String title;
  final Icon icon;
  const SecondPage(this.title,this.icon);
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        centerTitle: true,
        elevation: 0,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            this.icon,
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.arrow_back),
        onPressed: (){
          App.pop(context);
        },
      ),
    );
  }
}

''';
String sourceDemo09 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'data_source/post.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        centerTitle: true,
        elevation: 0,
        actions: <Widget>[
          IconSource("Form","09"),
        ],
      ),
      body: _FormDemo(),
    );
  }
}

class _FormDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _FormStateDemo();
  }
}

class _FormStateDemo extends State<_FormDemo> {
  final TextEditingController textEditingController = TextEditingController();
  final submitFormKey=GlobalKey<FormState>();
   String username;
   String password;
   bool _autovalidate=false;
   void _submitForm(){
     submitFormKey.currentState.save();
     if(submitFormKey.currentState.validate()){
       debugPrint("username:$username");
       debugPrint("password:$password");
       Scaffold.of(context).showSnackBar(
           SnackBar(content: Text("username:$username,password:$password"))
       );
     }else{
       setState(() {
         _autovalidate=true;
       });
     }

   }
   String _validateUsername(String value){
     if(value.isEmpty){
       return "username is request";
     }
     return null;
   }
   String _validatePassword(String value){
     if(value.isEmpty){
       return "password is request";
     }
     return null;
   }
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      //alignment: Alignment(0, 0),
      padding: EdgeInsets.all(10.0),
      //color: Theme.of(context).accentColor,
      child: Form(
        key: submitFormKey,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextFormField(
              decoration: InputDecoration(
                labelText: "username",
                hintText: "请输入用户名",
                helperText: "",
                icon: Icon(Icons.person),
              ),
              onSaved: (value) {
               username=value;
              },
              validator:_validateUsername,
              autovalidate: _autovalidate,
            ),
            TextFormField(
              obscureText: true,
              decoration: InputDecoration(
                  labelText: "password",
                  hintText: "请输入密码",
                  helperText: "",
                  icon: Icon(Icons.description)),
                  onSaved: (value) {
                    password=value;
                  },
                  validator: _validatePassword,
               autovalidate: _autovalidate,
            ),
//            TextField(
//              decoration: InputDecoration(
//                labelText: "mail",
//                icon: Icon(Icons.mail),
//              ),
////              onChanged: (value){
////                debugPrint("onChanged:$value");
////              },
//              controller: textEditingController,
//              onSubmitted: (value) {
//                debugPrint("onSubmitted:$value");
//              },
//              onEditingComplete: () {
//                debugPrint("onEditingComplete");
//              },
//            ),
            SizedBox(
              height: 20.0,
            ),
            Container(
              width: double.infinity,
              child: RaisedButton(
                color: Theme.of(context).primaryColor,
                child: Container(
                  padding: EdgeInsets.only(top:12.0,bottom: 12.0),
                  child: Text(
                    "submit",
                    style: TextStyle(color: Colors.white,),
                  ),
                ),
                onPressed: _submitForm,
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  void initState() {
    textEditingController.addListener(() {
      debugPrint("textEditingController:${textEditingController.text}");
    });
    super.initState();
  }

  @override
  void dispose() {
    textEditingController.dispose();
    super.dispose();
  }
}

''';
String sourceDemo10 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'package:intl/intl.dart';
import '../wonders/framework.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        centerTitle: true,
        elevation: 0,
        actions: <Widget>[
          IconSource("Button","10"),
        ],
      ),
      body: _ButtonDemo(),
    );
  }
}

class _ButtonDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView(
      children: <Widget>[
        ListItem("FloatingActionButton", _FloatActionButton()),
        ListItem("Button", _Button()),
        ListItem("PopupMenuButton", _PopupMenuButtonDemo()),
        ListItem("CheckBox", CheckBoxDemo()),
        ListItem("RadioBox", RadioBoxDemo()),
        ListItem("Switch", SwitchDemo()),
        ListItem("Slider", SliderDemo()),
        ListItem("DateTime", DateTimeDemo()),
        ListItem("Chip", ChipDemo()),
      ],
    );
  }
}

class ListItem extends StatelessWidget {
  final String title;
  final Widget page;
  const ListItem(this.title, this.page);
  @override
  Widget build(BuildContext context) {
    return ListTile(
      title: Text(this.title),
      onTap: () {
        Navigator.of(context)
            .push(MaterialPageRoute(builder: (context) => page));
      },
    );
  }
}

class _FloatActionButton extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _FloatActionButtonState();
}

class _FloatActionButtonState extends State<_FloatActionButton> {
  final floatActionButton = FloatingActionButton(
    child: Icon(Icons.add),
    onPressed: null,
    backgroundColor: Colors.black87,
    elevation: 0.0,
    shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
  );
  final floatActionButtonExent = FloatingActionButton.extended(
    onPressed: null,
    icon: Icon(Icons.add),
    label: Text("添加"),
  );
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("floatingActionButton"),
      ),
      floatingActionButton: floatActionButton,
      floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
      bottomNavigationBar: BottomAppBar(
        child: Container(
          height: 80.0,
        ),
      ),
    );
  }
}

class _Button extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final _imageButton = FlatButton(
      onPressed: () {},
      child: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Image(
              image: AssetImage("assets/images/jiaoyu.png"),
              height: 40.0,
            ),
            Text("school"),
          ],
        ),
      ),
    );
    final _flatButton = FlatButton(
      child: Text(
        "FlatButton",
      ),
      splashColor: Colors.white10,
      color: Theme.of(context).accentColor,
      onPressed: () {},
    );
    final _flatButtonIcon = FlatButton.icon(
      icon: Icon(
        Icons.save,
        color: Colors.white,
      ),
      label: Text(
        "FlatButton.icon",
        style: TextStyle(color: Colors.white),
      ),
      splashColor: Colors.white10,
      color: Theme.of(context).accentColor,
      onPressed: () {},
    );
    final _raiseButton = RaisedButton(
      child: Text(
        "RaisedButton",
        style: TextStyle(color: Colors.white),
      ),
      splashColor: Colors.white10,
      color: Theme.of(context).accentColor,
      elevation: 0.0,
      onPressed: () {},
    );
    final _raiseButtonIcon = RaisedButton.icon(
      icon: Icon(
        Icons.save,
        color: Colors.white,
      ),
      label: Text(
        "RaisedButton.icon",
        style: TextStyle(color: Colors.white),
      ),
      splashColor: Colors.white10,
      elevation: 20,
      color: Theme.of(context).accentColor,
      onPressed: () {},
    );
    final _outLineButton = OutlineButton(
      child: Text(
        "OutlineButton",
      ),
      splashColor: Colors.white10,
      onPressed: () {},
      textColor: Colors.black,
      borderSide: BorderSide(color: Colors.black87),
    );
    final _outLineButtonIcon = OutlineButton.icon(
      icon: Icon(
        Icons.save,
        color: Colors.white,
      ),
      highlightedBorderColor: Colors.grey,
      label: Text(
        "OutlineButton.icon",
      ),
      splashColor: Colors.white10,
      onPressed: () {},
    );
    final _themFlatButton = Theme(
      data: Theme.of(context).copyWith(
        //buttonColor: Theme.of(context).primaryColor,
        buttonColor: Colors.black87,
        buttonTheme: ButtonThemeData(
            //textTheme: ButtonTextTheme.primary,
            shape: StadiumBorder()),
      ),
      child: _flatButton,
    );
    return Scaffold(
      appBar: AppBar(title: Text("Button")),
      body: Container(
        alignment: Alignment(0.0, 0.0),
        padding: EdgeInsets.all(8.0),
        child: LinearLayout(
          //isVisible: true,
          orientation: Axis.vertical,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            _imageButton,
            SizedBox(
              height: 30.0,
            ),
            _themFlatButton,
           _flatButton,
            Container(
              width: double.infinity,
             child: _flatButtonIcon,
            ),
           _raiseButton,
            _raiseButtonIcon,
            _outLineButton,
            _outLineButtonIcon
          ],
        ),
      ),
    );
  }
}

class _PopupMenuButtonDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _PopupMenuButtonState();
}

class _PopupMenuButtonState extends State<_PopupMenuButtonDemo> {
  String _currentItemValue = "Select";
  @override
  Widget build(BuildContext context) {
    debugPrint("build execute!$_currentItemValue");
    _setSelect(value) {
      setState(() {
        _currentItemValue = value;
      });
    }

    return Scaffold(
      appBar: AppBar(
        title: Text("PopupMenuButton"),
      ),
      body: Container(
        padding: EdgeInsets.all(8.0),
        alignment: Alignment(0, 0),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(_currentItemValue),
            PopupMenuButton(
              icon: Icon(Icons.home),
              onSelected: _setSelect,
              itemBuilder: (BuildContext context) => [
                    PopupMenuItem(value: "HOME", child: Text("HOME")),
                    PopupMenuItem(
                        value: "DESCRIPTION", child: Text("DESCRIPTION")),
                    PopupMenuItem(value: "ABOUT", child: Text("ABOUT")),
                  ],
            )
          ],
        ),
      ),
    );
  }
}

class CheckBoxDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return CheckBoxStateDemo();
  }
}

class CheckBoxStateDemo extends State<CheckBoxDemo> {
  bool _checkBox = false;
  bool _checkBoxTile = false;
  String _checkBoxValue = "";
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("CheckBox"),
      ),
      body: Container(
        padding: EdgeInsets.all(10.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            CheckboxListTile(
              value: _checkBox,
              title: Text("CheckBoxItemA"),
              subtitle: Text("Subtitle"),
              secondary: Icon(Icons.label),
              selected: _checkBox,
              onChanged: (value) {
                setState(() {
                  _checkBox = value;
                });
              },
            ),
            Row(
              children: <Widget>[
                Checkbox(
                  value: _checkBoxTile,
                  onChanged: (value) {
                    setState(() {
                      _checkBoxTile = value;
                      _checkBoxValue = value ? "yes" : "no";
                    });
                  },
                ),
                Text("$_checkBoxValue"),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

class RadioBoxDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => RadioBoxStateDemo();
}

class RadioBoxStateDemo extends State<RadioBoxDemo> {
  int _groupValue = 1;
  int _groupValue2 = 3;
  _setRadio(value) {
    setState(() {
      _groupValue = value;
    });
  }

  _setRadio2(value) {
    setState(() {
      _groupValue2 = value;
    });
  }

  @override
  Widget build(BuildContext context) {
    debugPrint("groupvalue:$_groupValue");
    debugPrint("groupvalue2:$_groupValue2");
    return Scaffold(
      appBar: AppBar(
        title: Text("RadioBox"),
      ),
      body: Container(
        padding: EdgeInsets.all(10.0),
        child: Column(
          children: <Widget>[
            RadioListTile(
                title: Text("playboll"),
                subtitle: Text("subtitle playboll"),
                secondary: Icon(Icons.label),
                selected: _groupValue == 1,
                value: 1,
                groupValue: _groupValue,
                onChanged: _setRadio),
            RadioListTile(
                title: Text("swiming"),
                subtitle: Text("subtitle swiming"),
                secondary: Icon(Icons.mail),
                selected: _groupValue == 2,
                value: 2,
                groupValue: _groupValue,
                onChanged: _setRadio),
            Radio(
              value: 3,
              groupValue: _groupValue2,
              onChanged: _setRadio2,
              activeColor: Colors.black,
            ),
            Radio(
              value: 4,
              groupValue: _groupValue2,
              onChanged: _setRadio2,
              activeColor: Colors.black,
            )
          ],
        ),
      ),
    );
  }
}

class SwitchDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return SwitchStateDemo();
  }
}

class SwitchStateDemo extends State<SwitchDemo> {
  bool _switchValue = false;
  bool _switchListTile = false;
  @override
  Widget build(BuildContext context) {
    debugPrint("_switchValue:$_switchValue");
    debugPrint("_switchListTile:$_switchListTile");
    return Scaffold(
      appBar: AppBar(title: Text("Radio")),
      body: Container(
        alignment: Alignment(0.0, 0.0),
        padding: EdgeInsets.all(8.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Switch(
              value: _switchValue,
              onChanged: (value) {
                setState(() {
                  _switchValue = value;
                });
              },
            ),
            SwitchListTile(
                value: _switchListTile,
                title: Text("switchListTile"),
                subtitle: Text("subtitle switchList"),
                secondary: Icon(Icons.add_alarm),
                onChanged: (value) {
                  setState(() {
                    _switchListTile = value;
                  });
                })
          ],
        ),
      ),
    );
  }
}

class SliderDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return SliderStateDemo();
  }
}

class SliderStateDemo extends State<SliderDemo> {
  double _sliderItemValue = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Slider"),
      ),
      body: Container(
        margin: EdgeInsets.only(top: 50.0),
        child: ListView(
          children: <Widget>[
            Slider(
              value: _sliderItemValue,
              activeColor: Theme.of(context).primaryColor,
              inactiveColor: Theme.of(context).primaryColor.withOpacity(0.3),
              divisions: 100,
              min: 0,
              max: 100,
              label: "${_sliderItemValue.toInt()}",
              onChanged: (value) {
                setState(() {
                  _sliderItemValue = value;
                });
              },
            ),
            SizedBox(
              height: 10.0,
            ),
            Text("sliderValue:${_sliderItemValue.toInt()}")
          ],
        ),
      ),
    );
  }
}

class DateTimeDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return DateTimeState();
  }
}

class DateTimeState extends State<DateTimeDemo> {
  DateTime _selectDateTime = DateTime.now();
  TimeOfDay _timeOfDay = TimeOfDay(hour: 9, minute: 30);
  _showSelectDateTime() async {
    DateTime selectDatetime = await showDatePicker(
        context: context,
        initialDate: _selectDateTime,
        firstDate: DateTime(1900),
        lastDate: DateTime(2999));
    if (selectDatetime != null) {
      setState(() {
        _selectDateTime = selectDatetime;
      });
    }
  }

  _showSelectTime() async {
    TimeOfDay timeOfDay =
        await showTimePicker(context: context, initialTime: _timeOfDay);
    if (timeOfDay != null) {
      setState(() {
        _timeOfDay = timeOfDay;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("DateTime"),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          InkWell(
            onTap: _showSelectDateTime,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(DateFormat.yMd("zh").format(_selectDateTime)),
                Icon(Icons.arrow_drop_down),
              ],
            ),
          ),
          InkWell(
            onTap: _showSelectTime,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(_timeOfDay.format(context)),
                Icon(Icons.arrow_drop_down),
              ],
            ),
          )
        ],
      ),
    );
  }
}

class ChipDemo extends StatefulWidget {
  @override
  _ChipDemoState createState() => _ChipDemoState();
}

class SmallTip {
  final int id;
  final String title;
  SmallTip(this.id, this.title);
}

class _ChipDemoState extends State<ChipDemo> {
  List<SmallTip> _tips = [
    SmallTip(11, "apple"),
    SmallTip(22, "banana"),
    SmallTip(33, "lemon"),
  ];
  int _actionIndex = 0;
  List<SmallTip> _filterIndex = [];
  int _choiceIndex=0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Chip"),
      ),
      body: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Wrap(
              spacing: 10.0,
              runSpacing: 20.0,
              children: <Widget>[
                Chip(label: Text("apple")),
                Chip(
                  label: Text("banana"),
                  backgroundColor: Colors.yellow,
                ),
                Chip(
                  label: Text("lemon"),
                  backgroundColor: Theme.of(context).buttonColor,
                  avatar: CircleAvatar(
                    child: Text("柠"),
                    backgroundColor: Theme.of(context).accentColor,
                  ),
                ),
                Chip(
                  label: Text("orange"),
                  backgroundColor: Theme.of(context).buttonColor,
                  avatar: CircleAvatar(
                    backgroundImage: NetworkImage(
                        "http://pic1.16pic.com/00/13/30/16pic_1330257_b.jpg"),
                  ),
                ),
                Chip(
                  label: Text("potato"),
                  onDeleted: () {},
                  deleteButtonTooltipMessage: "delete potato",
                ),
              ],
            ),
            Divider(
              color: Colors.black38,
              height: 18.0,
            ),
            Wrap(
              alignment: WrapAlignment.start,
              spacing: 20.0,
              runSpacing: 10.0,
              children: _tips.map((SmallTip tip) {
                return Chip(
                  label: Text(tip.title),
                  onDeleted: () {
                    setState(() {
                      _tips.remove(tip);
                    });
                  },
                );
              }).toList(),
            ),
            Divider(
              color: Colors.black38,
              height: 18.0,
            ),
            Container(
              child: Text("ActionChip:$_actionIndex"),
            ),
            Wrap(
              spacing: 10.0,
              children: _tips.map((SmallTip tip) {
                return ActionChip(
                    label: Text(tip.title),
                    onPressed: () {
                      setState(() {
                        _actionIndex = tip.id;
                      });
                    });
              }).toList(),
            ),
            Divider(
              color: Colors.black38,
              height: 18.0,
            ),
            Container(
              child: Text("FilterChip:${_filterIndex.map((SmallTip tip){
                return tip!=null?tip.title:"";
              }).toList()}"),
            ),
            Wrap(
              spacing: 10.0,
              children: _tips.map((SmallTip tip) {
                return FilterChip(
                    selected: _filterIndex.contains(tip),
                    label: Text(tip.title),
                    onSelected: (isSelect){
                  setState(() {
                    _filterIndex.contains(tip)?_filterIndex.remove(tip):_filterIndex.add(tip);
                  });
                });
              }).toList(),
            ),
            Divider(height: 18.0,color: Colors.black87,),
            Container(
              child: Text("ChoiceChip:$_choiceIndex"),
            ),
            Wrap(
              spacing: 10.0,
              children: _tips.map((SmallTip tip) {
                return ChoiceChip(
                    selected:_choiceIndex==tip.id,
                    label: Text(tip.title),
                    onSelected: (isSelect){
                      setState(() {
                        isSelect?_choiceIndex=tip.id:null;
                      });
                    });
              }).toList(),
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.rotate_left),
        onPressed: () {
          setState(() {
            _tips = [
              SmallTip(11, "apple"),
              SmallTip(22, "banana"),
              SmallTip(33, "lemon"),
            ];
          });
        },
      ),
    );
  }
}

''';
String sourceDemo11 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import '../local/config/context.dart';
class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        centerTitle: true,
        elevation: 0,
        actions: <Widget>[
          IconSource("Dialog","11"),
        ],
      ),
      body: _DialogDemo(),
    );
  }
}

class ListItem extends StatelessWidget {
  final Widget widget;
  final String title;
  const ListItem(this.title, this.widget);
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return ListTile(
      title: Text(this.title),
      onTap: () {
        Navigator.of(context).push(MaterialPageRoute(builder: (context) {
          return widget;
        }));
      },
    );
  }
}

class _DialogDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return ListView(
      children: <Widget>[
        ListItem("SimpleDialog", SimpleDialogDemo()),
        ListItem("AlertDialog", ALertDialogDemo()),
        ListItem("BottomSheet", BottomSheetDemo()),
        ListItem("SnackBar", SnackBarDemo()),
        ListItem("ExpansionPanel", ExpansionPanelDemo()),
      ],
    );
  }
}

class SimpleDialogDemo extends StatefulWidget {
  @override
  _SimpleDialogDemoState createState() => _SimpleDialogDemoState();
}

enum Action { A, B, C }

class _SimpleDialogDemoState extends State<SimpleDialogDemo> {
  String _choice = "nothing";
  _showSimpleDialog() async {
    final action = await showDialog(
        //barrierDismissible:false,
        context: context,
        builder: (BuildContext context) {
          return SimpleDialog(
            title: Text("your choice?"),
            children: <Widget>[
              SimpleDialogOption(
                child: Text("option A"),
                onPressed: () {
                  App.pop(context, Action.A);
                },
              ),
              SimpleDialogOption(
                child: Text("option B"),
                onPressed: () {
                  Navigator.pop(context, Action.B);
                },
              ),
              SimpleDialogOption(
                child: Text("option C"),
                onPressed: () {
                  Navigator.pop(context, Action.C);
                },
              ),
            ],
          );
        });
    switch (action) {
      case Action.A:
        setState(() {
          _choice = "A";
        });
        break;
      case Action.B:
        setState(() {
          _choice = "B";
        });
        break;
      case Action.C:
        setState(() {
          _choice = "C";
        });
        break;
      default:
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("SimpleDialog")),
      body: Container(
        alignment: Alignment(0, 0),
        child: Text("your choice is: $_choice"),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.question_answer),
        onPressed: _showSimpleDialog,
      ),
    );
  }
}

class ALertDialogDemo extends StatefulWidget {
  @override
  _ALertDialogDemoState createState() => _ALertDialogDemoState();
}

class _ALertDialogDemoState extends State<ALertDialogDemo> {
  String _choice = "nothing";
  _openAlertDialog() async {
    final action = await showDialog(
        barrierDismissible: false,
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text("question"),
            content: Text("are you sure ?"),
            actions: <Widget>[
              FlatButton(
                child: Text("确定"),
                onPressed: () {
                  Navigator.pop(context, "OK");
                },
              ),
              FlatButton(
                child: Text("取消"),
                onPressed: () {
                  Navigator.pop(context, "CANCLE");
                },
              ),
            ],
          );
        });
    switch (action) {
      case "OK":
        setState(() {
          _choice = action;
        });
        break;
      case "CANCLE":
        setState(() {
          _choice = action;
        });
        break;
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("AlertDialog"),
      ),
      body: Container(
        alignment: Alignment(0, 0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text("your choice is：$_choice"),
            OutlineButton(
              child: Text("Open AlertDialog"),
              onPressed: _openAlertDialog,
            )
          ],
        ),
      ),
    );
  }
}

class BottomSheetDemo extends StatefulWidget {
  @override
  _BottomSheetDemoState createState() => _BottomSheetDemoState();
}

class _BottomSheetDemoState extends State<BottomSheetDemo> {
  final _bottomSheetScaffoldKey = GlobalKey<ScaffoldState>();
  String _choice="nothing";
  _openBottomSheet() {
    _bottomSheetScaffoldKey
        .currentState
        .showBottomSheet((BuildContext context){
          return BottomAppBar(
            child: Container(
              padding: EdgeInsets.only(left: 10.0),
              height: 90,
              child: Row(
                children: <Widget>[
                  Icon(Icons.info),
                  SizedBox(width: 30.0,),
                  Text("BottomAppBar"),
                  Expanded(
                    child: Text("do you have any other tip ?",textAlign: TextAlign.right,),
                  )
                ],
              ),
            ),
          );
    });
  }

 _openModelBottomSheet() async{
   final option= await showModalBottomSheet(context: context, builder: (BuildContext context){
      return Container(
        height: 280,
        padding: EdgeInsets.all(10.0),
        child: Column(
          children: <Widget>[
            ListTile(
              title: Text("option A"),
              onTap: (){
                Navigator.pop(context,"A");
              },
            ),
            ListTile(
              title: Text("option B"),
              onTap: (){
                Navigator.pop(context,"B");
              },
            ),
            ListTile(
              title: Text("option C"),
              onTap: (){
                Navigator.pop(context,"C");
              },
            ),
          ],
        ),
      );
    });
   setState(() {
     _choice=option;
   });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _bottomSheetScaffoldKey,
      appBar: AppBar(
        title: Text("BottomSheet"),
      ),
      body: Container(
        alignment: Alignment(0, 0),
        child:Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            OutlineButton(
              child: Text("Open BottomSheet"),
              onPressed: _openBottomSheet,
            ),
            OutlineButton(
              child: Text("Open Model BottomSheet"),
              onPressed: _openModelBottomSheet,
            ),
            Text("your choice is:$_choice"),
          ],
        ),
      ),
    );
  }
}

class SnackBarDemo extends StatefulWidget {
  @override
  _SnackBarDemoState createState() => _SnackBarDemoState();
}

class _SnackBarDemoState extends State<SnackBarDemo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("SnackBar"),),
      body: Container(
        alignment: Alignment(0, 0),
        child:ShowSnackButton() ,
      ),
    );
  }
}
class ShowSnackButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return OutlineButton(
      child: Text("Open SnackBar"),
      onPressed: (){
        Scaffold.of(context).showSnackBar(SnackBar(
          duration: Duration(seconds: 1),
          content: Text("this is a SnackBar"),
          action: SnackBarAction(
            label: "OK",
            onPressed: (){
              //Navigator.of(context).pop();
            },
          ),
        ));
      },
    );
  }
}

class ExpansionPanelDemo extends StatefulWidget {
  @override
  _ExpansionPanelDemoState createState() => _ExpansionPanelDemoState();
}

class _ExpansionPanelDemoState extends State<ExpansionPanelDemo> {
List<ExpansionPanelItem> _expanseonPanels=[
  ExpansionPanelItem(
    isExpanded: false,
    headerText: "header text A",
    widget: Container(
      padding: EdgeInsets.all(8.0),
      child: Text("This is  content A"),
    )
  ),
  ExpansionPanelItem(
    isExpanded: false,
    headerText: "header text B",
    widget: Container(
      padding: EdgeInsets.all(8.0),
      child: Text("This is  content B"),
    )
  ),
  ExpansionPanelItem(
    isExpanded: false,
    headerText: "header text C",
    widget: Container(
      padding: EdgeInsets.all(8.0),
      child: Text("This is  content C"),
    )
  ),
];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("ExpansionPanel"),),
      body: Container(
       padding: EdgeInsets.all(8.0),
        child: Column(
          children: <Widget>[
            ExpansionPanelList(
              expansionCallback: (int index,bool isExpand){
                setState(() {
                  _expanseonPanels[index].isExpanded=!isExpand;
                });
              },
              children: _expanseonPanels.map((ExpansionPanelItem item){
                return ExpansionPanel(
                    isExpanded: item.isExpanded,
                    headerBuilder: (BuildContext context, bool isExpanded){
                      return Container(
                        child: Container(
                          padding: EdgeInsets.all(10.0),
                          child: Text(item.headerText),
                        ),
                      );
                    },
                    body: item.widget
                );
              }).toList(),
            )
          ],
        ),
      ),
    );
  }
}

class ExpansionPanelItem {
  final Widget widget;
  final String headerText;
  bool isExpanded;
  ExpansionPanelItem({
    this.widget,this.headerText,this.isExpanded
});

}




''';
String sourceDemo12 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import '../demo/data_source/post.dart';
import '../wonders/framework.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: AppBar(
            title: Text(this.title),
            bottom: TabBar(
              tabs: <Widget>[
                Tab(text: "DataTable",),
                Tab(text: "PaginatedDataTable",)
              ],
            ),
            actions: <Widget>[
              IconSource("DataTable","12"),
            ],
          ),
          body: TabBarView(children: <Widget>[
            _DataTableDemo(),
            PaginateTableDemo()
          ]),
        )
    );
  }
}

class _DataTableDemo extends StatefulWidget {
  @override
  __DataTableDemoState createState() => __DataTableDemoState();
}

class __DataTableDemoState extends State<_DataTableDemo> {
  int _sortColumnIndex=0;
  bool _sortAscending = true;
  @override
  Widget build(BuildContext context) {
    return Container(
        child: ListView(
      children: <Widget>[
        TableLayout.table(
          key: GlobalKey(),
            sortColumnIndex: _sortColumnIndex,
            sortAscending: _sortAscending,
            columns: [
              DataColumn(
                  label: Container(
                    child: Text("Title"),
                    width: 80.0,
                  ),
                  onSort: (int columnIndex, bool sortAscending) {
                    _sortColumnIndex=columnIndex;
                    _sortAscending=sortAscending;
                    setState(() {
                      posts.sort((a,b){
                        if (!sortAscending) {
                          final c = a;
                          a = b;
                          b = c;
                        }
                        //return a.id.compareTo(b.id);
                        return a.title.compareTo(b.title);
                      });
                    });
                  }),
              DataColumn(label: Text("Autor"),
                  onSort: null),
              DataColumn(label: Text("Image")),
            ],
            rows: posts.map((Post post) {
              return DataRow(
                  selected: post.selected,
                  onSelectChanged: (bool isSelected){
                    setState(() {
                      if(isSelected!=null){
                        post.selected=isSelected;
                      }
                    });
                  },
                  cells: [
                DataCell(Text(post.title)),
                DataCell(Text(post.author)),
                DataCell(Image.network(post.imageUrl)),
              ]
              );
            }).toList()),
      ],
    ));
  }
}
class PaginateTableDemo extends StatefulWidget {
  @override
  _PaginateTableDemoState createState() => _PaginateTableDemoState();
}

class DataTableSourceDemo extends DataTableSource{
  List<Post> _posts=posts;
  int _selectCount=0;
  @override
  DataRow getRow(int index) {
      return DataRow.byIndex(
        index: index,
        cells: <DataCell>[
          DataCell(Text(_posts[index].title,)),
          DataCell(Text(_posts[index].author)),
          DataCell(Image.network(_posts[index].imageUrl)),
        ]
      );
  }

  @override
  int get selectedRowCount=>_selectCount;

  @override
  bool get isRowCountApproximate =>false;

  @override
  int get rowCount {
    return _posts.length;
  }
  _sort(int index,bool ascending){
    _posts.sort((a,b){
      if (!ascending) {
        final c = a;
        a = b;
        b = c;
      }
      return a.title.compareTo(b.title);
    });
    notifyListeners();
  }
}

class _PaginateTableDemoState extends State<PaginateTableDemo> {
  final DataTableSourceDemo dataTableSource=DataTableSourceDemo();
  int _sortColumnIndex=0;
  bool _sortAscending = true;
  @override
  Widget build(BuildContext context) {
    debugPrint("build _PaginateTableDemoState");
    return Container(
      child: ListView(
        children: <Widget>[
          TableLayout.pagedTable(
              sortColumnIndex: _sortColumnIndex,
              sortAscending: _sortAscending,
              rowsPerPage: 8,
              header: Text("PaginatedDataTable"),
              columns: [
                DataColumn(
                    label: Container(
                      child: Text("Title"),
                    ),
                  onSort: (int columIndex,bool ascending){
                    dataTableSource._sort(columIndex,ascending);
                      setState(() {
                        _sortColumnIndex=columIndex;
                        _sortAscending=ascending;
                      });

                  }
                ),
                DataColumn(label: Text("Author")),
                DataColumn(label: Text("Image")),
              ],
              source: dataTableSource
          )
        ],
      ),
    );
  }
}


''';
String sourceDemo13 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import '../demo/data_source/post.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
   return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("Card","13"),
        ],
      ),
      body: CardDemo(),
    );
  }
}

class CardDemo extends StatefulWidget {
  @override
  CardDemoState createState() => CardDemoState();
}

class CardDemoState extends State<CardDemo> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(8.0),
      child: ListView(
        children: posts.map((post){
          return Card(
            child: Column(
              children: <Widget>[
                AspectRatio(
                  aspectRatio: 16/9,
                  child: ClipRRect(
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(4.0),
                      topRight: Radius.circular(4.0),
                    ),
                    child: Image.network(post.imageUrl,fit: BoxFit.cover,),
                  ),
                ),
                ListTile(
                  title: Text(post.title),
                  subtitle: Text(post.author),
                  leading: CircleAvatar(
                    backgroundImage:NetworkImage(post.imageUrl) ,
                  ),
                ),
                Container(
                  padding: EdgeInsets.all(10),
                  child: Text(post.description),
                ),
                ButtonTheme.bar(
                  child: ButtonBar(
                    children: <Widget>[
                      FlatButton(
                        child: Text("LIKE"),
                        onPressed: (){},
                      ),
                      FlatButton(
                        child: Text("READ"),
                        onPressed: (){},
                      ),
                    ],
                  ),
                )
              ],
            ),
          );
        }).toList(),
      ),
    );
  }
}



''';
String sourceDemo14 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import '../demo/data_source/post.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});


  @override
  Widget build(BuildContext context) {
    return  Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("Steper","14"),
        ],
      ),
      body: Theme(data: Theme.of(context).copyWith(
        primaryColor: Colors.black
      ),
          child: SteperDemo()
      ),
    );
  }
}
class SteperDemo extends StatefulWidget {
  @override
  _SteperDemoState createState() => _SteperDemoState();
}

class _SteperDemoState extends State<SteperDemo> {
  int _isAction=0;
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(8.0),
      child: Stepper(
        currentStep: _isAction,
        onStepTapped: (int value){
          setState(() {
            _isAction=value;
          });
        },
        onStepContinue: (){
         setState(() {
           _isAction>=2?_isAction=2:_isAction+=1;
         });
        },
        onStepCancel: (){
          setState(() {
            _isAction>0?_isAction-=1:_isAction=0;
          });
        },
        steps: <Step>[
          Step(
            title: Text("第一步"),
            subtitle: Text("把冰箱门打开"),
            content: Text("找个大点的冰箱，断电，打开冰箱门"),
            isActive: _isAction==0,
          ),
          Step(
            title: Text("第二步"),
            subtitle: Text("把大象装进去"),
            content: Text("找个小点的大象，塞进冰箱"),
            isActive: _isAction==1,
          ),
          Step(
            title: Text("第三步"),
            subtitle: Text("把冰箱门关上"),
            content: Text("视情况而定，如果确实关不上，就开着吧"),
            isActive: _isAction==2,
          ),
        ],
      ),
    );
  }
}



''';
String sourceDemo15 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: AppBar(
            title: Text(this.title),
            actions: <Widget>[
              IconSource("State","15"),
            ],
          ),
          body: StateDemo(),
        )
    );
  }
}
class StateDemo extends StatefulWidget {
  @override
  _StateDemoState createState() => _StateDemoState();
}

class _StateDemoState extends State<StateDemo> {
  int count=0;
   _increseCount(){
     setState(() {
       count+=1;
     });
   }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
    body: Container(
      child: Center(
        child: CounterDemo(_increseCount, count),
      ),
    ),
      floatingActionButton: FloatingActionButton(
        onPressed: _increseCount,
        child: Icon(Icons.add),
      ),
    );
  }
}
class CounterDemo extends StatelessWidget {
  final VoidCallback increseCount;
  final int count;
  CounterDemo(this.increseCount,this.count);
  @override
  Widget build(BuildContext context) {
    return Center(
      child: ActionChip(label: Text("$count"), onPressed: increseCount),
    );
  }
}




''';
String sourceDemo16 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: AppBar(
            title: Text(this.title),
            actions: <Widget>[
              IconSource("InheritiedWidget","16"),
            ],
          ),
          body: StateDemo(),
        )
    );
  }
}


class CounterProvider extends InheritedWidget{
  final List<String> fruits;
  final VoidCallback onFresh;
  final ValueChanged<String> deleteItem;
  final Widget child;
  CounterProvider({this.fruits,this.onFresh,this.deleteItem,this.child}):super(child:child);

  @override
  bool updateShouldNotify(InheritedWidget oldWidget) {
    return true;
  }
  static CounterProvider of(BuildContext context){
      return context.inheritFromWidgetOfExactType(CounterProvider);
  }
}

class StateDemo extends StatefulWidget {
  @override
  _StateDemoState createState() => _StateDemoState();
}

class _StateDemoState extends State<StateDemo> {
   List<String> fruits=['apple','oragen','banana'];
   _onFresh(){
    setState(() {
      fruits=['apple','oragen','banana'];
    });
  }
  _deleteItem(String item){
    setState(() {
     fruits.remove(item);
    });
  }
  @override
  Widget build(BuildContext context) {
    return CounterProvider(
      fruits: fruits,
      onFresh: _onFresh,
      deleteItem: _deleteItem,
      child: Scaffold(
        body: Container(
          child: Center(
            child: CounterWrapper(),
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _onFresh,
          child: Icon(Icons.refresh),
        ),
      ),
    );
  }
}
class CounterWrapper extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: CounterDemo(),
    );
  }
}

class CounterDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
     List<String> fruits=CounterProvider.of(context).fruits;
     VoidCallback onFresh=CounterProvider.of(context).onFresh;
     ValueChanged<String> deleteItem=CounterProvider.of(context).deleteItem;
    return Center(
      child:Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Wrap(
            spacing: 10.0,
            children: fruits.map((item){
              return Chip(
                label: Text("${item}"),
                onDeleted:(){
                  deleteItem(item);
                },
              );
            }).toList(),
          ),
          Divider(height: 18.0,),
          FlatButton(onPressed: (){
            onFresh();
          }, child: Text("刷新"))
        ],
      ),
    );
  }
}




''';
String sourceDemo17 = r'''
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:wonders_one_demo/local/model/app_model.dart';
class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("ScopedModel","17"),
        ],
      ),
      body: StateDemo(),
    );
  }
}

class CounterModel extends Model {
   List<String> _fruits = ['apple', 'oragen', 'banana'];
   void onFresh () {
    _fruits = ['apple', 'oragen', 'banana'];
    notifyListeners();
  }
  void deleteItem(value) {
    _fruits.remove(value);
    notifyListeners();
  }
  List<String> get fruits => _fruits;
   static CounterModel of(BuildContext context,[bool rebuildOnChange]){
     if(rebuildOnChange!=null)
        return ScopedModel.of(context,rebuildOnChange: rebuildOnChange);
      return ScopedModel.of(context);
   }
}

class StateDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ScopedModel(
      model: CounterModel(),
      child: Scaffold(
        body: Container(
          child: Center(
            child: CounterWrapper(),
          ),
        ),
        floatingActionButton: ScopedModelDescendant<CounterModel>(
          rebuildOnChange: false,
          builder: (context, _, model) {
            return FloatingActionButton(
              onPressed: model.onFresh,
              child: Icon(Icons.refresh),
            );
          },
        ),
      ),
    );
  }
}

class CounterWrapper extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: CounterDemo(),
    );
  }
}

class CounterDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text("项目名称："+BaseModel.of<AppModel>(context).get("appName")),
          ScopedModelDescendant<CounterModel>(
            builder: (context, _, model) {
              return Wrap(
                spacing: 10.0,
                children: model.fruits.map((item) {
                  return Chip(
                    label: Text("${item}"),
                    onDeleted: () {
                      model.deleteItem(item);
                    },
                  );
                }).toList(),
              );
            },
          ),
          Divider(
            height: 18.0,
          ),
         ScopedModelDescendant<CounterModel>(
           builder: (context,_,model){
             return  OutlineButton(
               onPressed: () {
                 model.onFresh();
               },
               child: Text("刷新1"),
             );
           },
         ),
          OutlineButton(
            onPressed: () {
              CounterModel.of(context).onFresh();
            },
            child: Text("刷新2"),
          )
        ],
      ),
    );
  }
}

''';
String sourceDemo18 = r'''
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("Stream","18"),
        ],
      ),
      body:StreamDemo() ,
    );
  }
}
class StreamDemo extends StatefulWidget {
  @override
  _StreamDemoState createState() => _StreamDemoState();
}

class _StreamDemoState extends State<StreamDemo> {

  StreamController<String> streamController;
  StreamSubscription subscription;
  String _subLogs="...";
  @override
  void initState() {
    super.initState();
    streamController=StreamController<String>.broadcast();
    subscription=streamController.stream.listen(onData,onDone: _onDone);
  }
  void _add() async{
      String value=await getData();
    streamController.sink.add(value);
  }
  Future<String> getData() async{
    await Future.delayed(Duration(seconds: 1));
    return "hello!!";
  }
  void _onDone(){
    setState(() {
      _subLogs=_subLogs+"done\n";
    });
  }
  void onData(value){
    setState(() {
      _subLogs=_subLogs+value+"\n";
    });
  }
  void onPause(){
    subscription.pause();
    setState(() {
      _subLogs=_subLogs+"pause\n";
    });
  }
  void onResume(){
    subscription.resume();
    setState(() {
      _subLogs=_subLogs+"resume\n";
    });
  }
  void onCancle(){
    subscription.cancel();
    setState(() {
      _subLogs=_subLogs+"cancle\n";
    });
  }
  @override
  Widget build(BuildContext context) {
    debugPrint("build widgte");
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          //Text(_result),
          StreamBuilder<String>(
            stream: streamController.stream,
            initialData: "....",
            builder: (context,snapshot){
              return Text("${snapshot.data}");
            },
          ),
          Wrap(
            spacing: 3.0,
            children: <Widget>[
              OutlineButton(
                child: Text("add"),
                onPressed: _add,
              ),
              OutlineButton(
                child: Text("pause"),
                onPressed: onPause,
              ),
              OutlineButton(
                child: Text("resume"),
                onPressed: onResume,
              ),
              OutlineButton(
                child: Text("cancle"),
                onPressed: onCancle,
              ),
            ],
          ),
          ListTile(
            title: Text("log："),
            subtitle: Text(_subLogs),
          ),
        ],
      ),
    );
  }
  @override
  void dispose() {
    super.dispose();
    streamController.close();
    debugPrint("demo18 disposed!");
  }
}



''';
String sourceDemo19 = r'''
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'package:rxdart/rxdart.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("RxDart","19"),
        ],
      ),
      body:RxDartDemo() ,
    );
  }
}
class RxDartDemo extends StatefulWidget {
  @override
  _RxDartDemoState createState() => _RxDartDemoState();
}

class _RxDartDemoState extends State<RxDartDemo> {

  PublishSubject subject;
  String _log="...";
  @override
  initState(){
    super.initState();
    subject=PublishSubject<String>();
    subject.debounceTime(Duration(milliseconds: 500)).listen((value){
      setState(() {
        _log=value;
      });
    });
  }

  _onChanged(value){
    subject.add(value);
  }
  @override
  void dispose() {
    super.dispose();
    subject.close();
  }
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(8.0),
      child:Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextField(
              onChanged:_onChanged,
              decoration: InputDecoration(
                hintText: "请输入",
                icon: Icon(Icons.person),
              ),
            ),
            ListTile(
              title: Text("延迟500毫秒判断："),
              subtitle: Text(_log),
            ),
          ],
        ),
      ),
    );
  }
}



''';
String sourceDemo20 = r'''
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});
  @override
  Widget build(BuildContext context) {
    return CounterProvider(
      counterModel: CounterModel(),
      child: Scaffold(
        appBar: AppBar(
          title: Text(this.title),
          actions: <Widget>[
            IconSource("Bloc","20"),
          ],
        ),
        body:BlocDemo(),
        floatingActionButton: FloatingActionButtonDemo(),
      ),
    );
  }
}
class BlocDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    CounterProvider counterProvider=CounterProvider.of(context);
    return StreamBuilder(
      stream: counterProvider.counterModel.streamControllerOut.stream,
      builder: (context,snapshot){
        return Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              ActionChip(
                label: Text("${snapshot.data==null?0:snapshot.data}"),
                onPressed: ()=>counterProvider.counterModel.sinkIn.add(1),
              ),
              OutlineButton(
                child: Text("get network data"),
                onPressed: ()=>counterProvider.counterModel.request(),
              ),
              ListTile(
                title: Text("日志："),
                subtitle: Text(counterProvider.counterModel.log),
              ),
            ],
          ),
        );
      },
    );
  }
}
class FloatingActionButtonDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    CounterProvider counterProvider=CounterProvider.of(context);
    return FloatingActionButton(
      child: Icon(Icons.add),
      onPressed: ()=>counterProvider.counterModel.sinkIn.add(1)
    );
  }
}

class CounterModel {
  String log="...";
  int _count=0;
  int get count=>_count;
  final StreamController streamControllerIn=StreamController();
  StreamSink get sinkIn=>streamControllerIn.sink;
  final StreamController streamControllerOut=StreamController();
  StreamSink get sinkOut=>streamControllerOut.sink;
  CounterModel(){
    streamControllerIn.stream.listen(onData);
  }
  void onData(value){
    _count+=1;
    streamControllerOut.sink.add(_count);
  }
  //模仿从后台获取数据
  void request() async{
     log=log+"后台获取数据...\n";
     int value= await getData();
    _count+=value;
    streamControllerOut.sink.add(_count);
  }
  Future<int> getData() async{
    await Future.delayed(Duration(seconds: 2));
    debugPrint("getData");
    log=log+"获取数据:2\n";
    return 2;
  }
}

class CounterProvider extends InheritedWidget {
  final CounterModel counterModel;
  const CounterProvider({
    Key key,
    this.counterModel,
    @required Widget child,
  })
      : assert(child != null),
        super(key: key, child: child);

  static CounterProvider of(BuildContext context) {
    return context.inheritFromWidgetOfExactType(
        CounterProvider) as CounterProvider;
  }

  @override
  bool updateShouldNotify(CounterProvider old) {
    return false;
  }
}



''';
String sourceDemo21 = r'''
import 'dart:async';
import 'dart:convert' show json;

import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import '../demo/data_source/post.dart';
import 'package:http/http.dart' as http;
class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("http","21"),
        ],
      ),
      body:HttpDemo(),
    );
  }
}
class HttpDemo extends StatefulWidget {
  @override
  _HttpDemoState createState() => _HttpDemoState();
}

class _HttpDemoState extends State<HttpDemo> {
  List<Post> posts;
  @override
  void initState() {
    super.initState();

  }

  Future<List<Post>> fetchPosts() async{
    List<Post> posts;
    http.Response response= await  http.get("https://resources.ninghao.net/demo/posts.json");
    if(response.statusCode==200){
      print("body type:${json.decode(response.body).runtimeType}");
     Map map= json.decode(response.body);
     List list=map['posts'];
     return list.map((item)=>Post.fromJson(item)).toList();
    } else {
      throw Exception('Failed to fetch posts.');
    }
  }
  @override
  Widget build(BuildContext context) {
    return Container(
      child: FutureBuilder(
          future: fetchPosts(),
          builder: (BuildContext context,AsyncSnapshot snapshot){
            print("sanpshot type:${snapshot.data.runtimeType}");
          if(snapshot.connectionState==ConnectionState.waiting){
            return Center(child: Text("loading....."),);
          }
          return ListView(
            children: snapshot.data.map<Widget>((item){
              return ListTile(
                title: Text(item.title),
                subtitle: Text(item.author),
                leading: CircleAvatar(
                  backgroundImage:NetworkImage(item.imageUrl) ,
                ),
              );
            }).toList(),
          );
      }),
    );
  }
}




''';
String sourceDemo22 = r'''
import 'dart:async';
import 'dart:convert' show json;

import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import '../demo/data_source/post.dart';
import 'package:http/http.dart' as http;
class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("Animation","22"),
        ],
      ),
      body:AnimationDemo(),
    );
  }
}

class AnimationDemo extends StatefulWidget {
  @override
  _AnimationDemoState createState() => _AnimationDemoState();
}

class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateMixin {
  AnimationController animationController;
  Animation animation;
  Animation animationColor;
  CurvedAnimation curvedAnimation;
  @override
  void initState() {
    super.initState();
    animationController=AnimationController(
      duration: Duration(milliseconds: 2000),
      vsync: this,
    );
    curvedAnimation=CurvedAnimation(parent: animationController, curve: Curves.bounceInOut);
    animation=Tween(begin: 30.0,end: 100.0).animate(curvedAnimation);
    animationColor=ColorTween(begin: Colors.red,end: Colors.red[900]).animate(curvedAnimation);
//    animationController.addListener((){
//      setState(() {
//      });
//    });
    animationController.addStatusListener((AnimationStatus status){
      print(status);
    });
  }

  @override
  void dispose() {
    super.dispose();
    animationController.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return AnimationHeartDemo(animationController: animationController,animations: [animation,animationColor],);
  }
}
class AnimationHeartDemo extends AnimatedWidget{
  final List<Animation> animations;
  final AnimationController animationController;
  const AnimationHeartDemo({this.animationController,this.animations}):super(listenable:animationController);
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Center(
      child: IconButton(
          icon: Icon(Icons.favorite),
          iconSize: animations[0].value,
          color: animations[1].value,
          onPressed: (){
            switch(animationController.status){
              case AnimationStatus.completed :
                animationController.reverse();
                break;
              default:
                animationController.forward();
            }
          }
      ),
    );
  }

}


''';
String sourceDemo23 = r'''
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'package:camera/camera.dart';
import 'package:path_provider/path_provider.dart';
import 'package:video_player/video_player.dart';
import '../local/model/app_model.dart';
class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("Camera","23"),
        ],
      ),
      body:CameraExampleHome(),
    );
  }
}
class CameraExampleHome extends StatefulWidget {
  @override
  _CameraExampleHomeState createState() {
    return _CameraExampleHomeState();
  }
}

/// Returns a suitable camera icon for [direction].
IconData getCameraLensIcon(CameraLensDirection direction) {
  switch (direction) {
    case CameraLensDirection.back:
      return Icons.camera_rear;
    case CameraLensDirection.front:
      return Icons.camera_front;
    case CameraLensDirection.external:
      return Icons.camera;
  }
  throw ArgumentError('Unknown lens direction');
}

void logError(String code, String message) =>
    print('Error: $code\nError Message: $message');

class _CameraExampleHomeState extends State<CameraExampleHome>
    with WidgetsBindingObserver {
  CameraController controller;
  String imagePath;
  String videoPath;
  VideoPlayerController videoController;
  VoidCallback videoPlayerListener;

  @override
  void initState()  {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if (state == AppLifecycleState.inactive) {
      controller?.dispose();
    } else if (state == AppLifecycleState.resumed) {
      if (controller != null) {
        onNewCameraSelected(controller.description);
      }
    }
  }

  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldKey,
      body: Column(
        children: <Widget>[
          Expanded(
            child: Container(
              child: Padding(
                padding: const EdgeInsets.all(1.0),
                child: Center(
                  child: _cameraPreviewWidget(),
                ),
              ),
              decoration: BoxDecoration(
                color: Colors.black,
                border: Border.all(
                  color: controller != null && controller.value.isRecordingVideo
                      ? Colors.redAccent
                      : Colors.grey,
                  width: 3.0,
                ),
              ),
            ),
          ),
          _captureControlRowWidget(),
          Padding(
            padding: const EdgeInsets.all(5.0),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                _cameraTogglesRowWidget(),
                _thumbnailWidget(),
              ],
            ),
          ),
        ],
      ),
    );
  }

  /// Display the preview from the camera (or a message if the preview is not available).
  Widget _cameraPreviewWidget() {
    if (controller == null || !controller.value.isInitialized) {
      return const Text(
        'Select a camera',
        style: TextStyle(
          color: Colors.white,
          fontSize: 24.0,
          fontWeight: FontWeight.w900,
        ),
      );
    } else {
      return AspectRatio(
        aspectRatio: controller.value.aspectRatio,
        child: CameraPreview(controller),
      );
    }
  }

  /// Display the thumbnail of the captured image or video.
  Widget _thumbnailWidget() {
    return Expanded(
      child: Align(
        alignment: Alignment.centerRight,
        child: videoController == null && imagePath == null
            ? null
            : SizedBox(
          child: (videoController == null)
              ? Image.file(File(imagePath))
              : Container(
            child: Center(
              child: AspectRatio(
                  aspectRatio: videoController.value.size != null
                      ? videoController.value.aspectRatio
                      : 1.0,
                  child: VideoPlayer(videoController)),
            ),
            decoration: BoxDecoration(
                border: Border.all(color: Colors.pink)),
          ),
          width: 64.0,
          height: 64.0,
        ),
      ),
    );
  }

  /// Display the control bar with buttons to take pictures and record videos.
  Widget _captureControlRowWidget() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      mainAxisSize: MainAxisSize.max,
      children: <Widget>[
        IconButton(
          icon: const Icon(Icons.camera_alt),
          color: Colors.blue,
          onPressed: controller != null &&
              controller.value.isInitialized &&
              !controller.value.isRecordingVideo
              ? onTakePictureButtonPressed
              : null,
        ),
        IconButton(
          icon: const Icon(Icons.videocam),
          color: Colors.blue,
          onPressed: controller != null &&
              controller.value.isInitialized &&
              !controller.value.isRecordingVideo
              ? onVideoRecordButtonPressed
              : null,
        ),
        IconButton(
          icon: const Icon(Icons.stop),
          color: Colors.red,
          onPressed: controller != null &&
              controller.value.isInitialized &&
              controller.value.isRecordingVideo
              ? onStopButtonPressed
              : null,
        )
      ],
    );
  }

  /// Display a row of toggle to select the camera (or a message if no camera is available).
  Widget _cameraTogglesRowWidget() {
    final List<Widget> toggles = <Widget>[];
    //获取相机
    List<CameraDescription> cameras=BaseModel.of<AppModel>(context).cameras;
    if (cameras.isEmpty) {
      return const Text('No camera found');
    } else {
      for (CameraDescription cameraDescription in cameras) {
        toggles.add(
          SizedBox(
            width: 90.0,
            child: RadioListTile<CameraDescription>(
              title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
              groupValue: controller?.description,
              value: cameraDescription,
              onChanged: controller != null && controller.value.isRecordingVideo
                  ? null
                  : onNewCameraSelected,
            ),
          ),
        );
      }
    }

    return Row(children: toggles);
  }

  String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();

  void showInSnackBar(String message) {
    _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(message)));
  }

  void onNewCameraSelected(CameraDescription cameraDescription) async {
    if (controller != null) {
      await controller.dispose();
    }
    controller = CameraController(cameraDescription, ResolutionPreset.high);

    // If the controller is updated then update the UI.
    controller.addListener(() {
      if (mounted) setState(() {});
      if (controller.value.hasError) {
        showInSnackBar('Camera error ${controller.value.errorDescription}');
      }
    });

    try {
      await controller.initialize();
    } on CameraException catch (e) {
      _showCameraException(e);
    }

    if (mounted) {
      setState(() {});
    }
  }

  void onTakePictureButtonPressed() {
    takePicture().then((String filePath) {
      if (mounted) {
        setState(() {
          imagePath = filePath;
          videoController?.dispose();
          videoController = null;
        });
        if (filePath != null) showInSnackBar('Picture saved to $filePath');
      }
    });
  }

  void onVideoRecordButtonPressed() {
    startVideoRecording().then((String filePath) {
      if (mounted) setState(() {});
      if (filePath != null) showInSnackBar('Saving video to $filePath');
    });
  }

  void onStopButtonPressed() {
    stopVideoRecording().then((_) {
      if (mounted) setState(() {});
      showInSnackBar('Video recorded to: $videoPath');
    });
  }

  Future<String> startVideoRecording() async {
    if (!controller.value.isInitialized) {
      showInSnackBar('Error: select a camera first.');
      return null;
    }

    final Directory extDir = await getApplicationDocumentsDirectory();
    final String dirPath = '${extDir.path}/Movies/flutter_test';
    await Directory(dirPath).create(recursive: true);
    final String filePath = '$dirPath/${timestamp()}.mp4';

    if (controller.value.isRecordingVideo) {
      // A recording is already started, do nothing.
      return null;
    }

    try {
      videoPath = filePath;
      await controller.startVideoRecording(filePath);
    } on CameraException catch (e) {
      _showCameraException(e);
      return null;
    }
    return filePath;
  }

  Future<void> stopVideoRecording() async {
    if (!controller.value.isRecordingVideo) {
      return null;
    }

    try {
      await controller.stopVideoRecording();
    } on CameraException catch (e) {
      _showCameraException(e);
      return null;
    }

    await _startVideoPlayer();
  }

  Future<void> _startVideoPlayer() async {
    final VideoPlayerController vcontroller =
    VideoPlayerController.file(File(videoPath));
    videoPlayerListener = () {
      if (videoController != null && videoController.value.size != null) {
        // Refreshing the state to update video player with the correct ratio.
        if (mounted) setState(() {});
        videoController.removeListener(videoPlayerListener);
      }
    };
    vcontroller.addListener(videoPlayerListener);
    await vcontroller.setLooping(true);
    await vcontroller.initialize();
    await videoController?.dispose();
    if (mounted) {
      setState(() {
        imagePath = null;
        videoController = vcontroller;
      });
    }
    await vcontroller.play();
  }

  Future<String> takePicture() async {
    if (!controller.value.isInitialized) {
      showInSnackBar('Error: select a camera first.');
      return null;
    }
    final Directory extDir = await getApplicationDocumentsDirectory();
    final String dirPath = '${extDir.path}/Pictures/flutter_test';
    await Directory(dirPath).create(recursive: true);
    final String filePath = '$dirPath/${timestamp()}.jpg';

    if (controller.value.isTakingPicture) {
      // A capture is already pending, do nothing.
      return null;
    }

    try {
      await controller.takePicture(filePath);
    } on CameraException catch (e) {
      _showCameraException(e);
      return null;
    }
    return filePath;
  }

  void _showCameraException(CameraException e) {
    logError(e.code, e.description);
    showInSnackBar('Error: ${e.code}\n${e.description}');
  }
}

class CameraApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: CameraExampleHome(),
    );
  }
}




''';
String sourceDemo24 = r''' 
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(title: this.title,);
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("shared_preferences","24"),
        ],
      ),
      body:SharedPreferencedDemo(),
    );
  }
}
class SharedPreferencedDemo extends StatefulWidget {
  @override
  _SharedPreferencedDemoState createState() => _SharedPreferencedDemoState();
}

class _SharedPreferencedDemoState extends State<SharedPreferencedDemo> {
  String _value="";
   String filePath;
  SharedPreferences sp;
  TextEditingController controller=TextEditingController();
  @override
  void initState() {
    super.initState();
    _initSharedPreference();

  }
  String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
  _initSharedPreference() async{
    sp=await SharedPreferences.getInstance();
    //Directory directory=await getApplicationDocumentsDirectory();
    Directory directory=await getTemporaryDirectory();
    String tempDir=directory.path;
    filePath=tempDir+"/${timestamp()}.txt";
  }
  _readValue(){
    setState(() {
      _value=sp.getString("key");
    });
  }
  _saveToFile() async{

    File file=File(filePath);
    file.writeAsStringSync(controller.text,mode: FileMode.append);
  }
  _readFromFile() async{
    File file=File(filePath);
    file.readAsString().then((String content){
      setState(() {
        _value="filePath:$filePath\n content:$content";
      });
    });

  }
  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: <Widget>[
          TextField(
            controller: controller,
            decoration: InputDecoration(
              hintText: "please input"
            ),
          ),
          Wrap(
            spacing: 8.0,
            children: <Widget>[
              OutlineButton(
                child: Text("save"),
                onPressed: (){
                  sp.setString("key", controller.text);
                },
              ),
              OutlineButton(
                child: Text("read"),
                onPressed: _readValue,
              ),
            ],
          ),
          Wrap(
            spacing: 8.0,
            children: <Widget>[
              OutlineButton(
                child: Text("saveToFile"),
                onPressed: _saveToFile,
              ),
              OutlineButton(
                child: Text("readFromFile"),
                onPressed: _readFromFile,
              )
            ],
          ),
          ListTile(
            title:Text("结果") ,
            subtitle: Text(_value),
          ),
        ],
      ),
    );
  }
}



''';
String sourceDemo25 = r'''
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:wonders_one_demo/demo/ui_demo.dart';
import 'package:wonders_one_demo/wonders/utils/device_utils.dart';
import 'package:connectivity/connectivity.dart';

class MyDemo extends StatelessWidget implements Demo {
  MyDemo(this.title);
  @override
  String title;
  @override
  Widget build(BuildContext context) {
    return new HomePage(
      title: this.title,
    );
  }
}

class HomePage extends StatelessWidget {
  String title;
  HomePage({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
        actions: <Widget>[
          IconSource("local","25"),
        ],
      ),
      body: LocalEnvDemo(),
    );
  }
}

class LocalEnvDemo extends StatefulWidget {
  @override
  _LocalEnvDemoState createState() => _LocalEnvDemoState();
}

class _LocalEnvDemoState extends State<LocalEnvDemo> {
  String _devInfo = "";
  String _netInfo = "";
  @override
  Widget build(BuildContext context) {
    return ListView(
      children: <Widget>[
        RaisedButton(
            child: Text("打开网络设置"),
            onPressed: () {
              DeviceUtils.openWIFISettings();
            }),
        RaisedButton(
            child: Text("打开位置设置"),
            onPressed: () {
              DeviceUtils.openLocationSettings();
            }),
        RaisedButton(
            child: Text("打开APP设置"),
            onPressed: () {
              DeviceUtils.openAppSettings();
            }),
        RaisedButton(
            child: Text("打开安全设置"),
            onPressed: () {
              DeviceUtils.openSecuritySettings();
            }),
        RaisedButton(
            child: Text("机器信息"),
            onPressed: () {
              getDeviceInfo();
            }),
        RaisedButton(
            child: Text("网络状态"),
            onPressed: () {
              getNetInfo();
            }),
        ListTile(
          title: Text("机器信息："),
          subtitle: Text("$_devInfo"),
        ),
        ListTile(
          title: Text("网络信息："),
          subtitle: Text("$_netInfo"),
        ),
      ],
    );
  }

  getDeviceInfo() async {
    List<String> infos = [];
    infos.add("Platform.isAndroid->${DeviceUtils.isAndroid}");
    infos.add("Platform.isIOS->${DeviceUtils.isIos}");

    DeviceUtils.deviceInfo.then((info) {
      if (DeviceUtils.isAndroid) {
        infos.add(
            'model-> ${info.androidDeviceInfo.model}'); // e.g. "Moto G (4)"
        infos.add('id-> ${info.androidDeviceInfo.id}'); // e.g. "Moto G (4)"
        infos.add('type-> ${info.androidDeviceInfo.type}'); // e.g. "Moto G (4)"
        infos.add(
            'androidId->${info.androidDeviceInfo.androidId}'); // e.g. "Moto G (4)"
        infos.add(
            'board-> ${info.androidDeviceInfo.board}'); // e.g. "Moto G (4)"
        infos.add(
            'bootloader-> ${info.androidDeviceInfo.bootloader}'); // e.g. "Moto G (4)"
        infos.add(
            'brand-> ${info.androidDeviceInfo.brand}'); // e.g. "Moto G (4)"
        infos.add(
            'device-> ${info.androidDeviceInfo.device}'); // e.g. "Moto G (4)"
        infos.add(
            'display-> ${info.androidDeviceInfo.display}'); // e.g. "Moto G (4)"
//      infos.add(
//          'fingerinfos.add-> ${info.androidDeviceInfo.fingerinfos.add}'); // e.g. "Moto G (4)"
        infos.add(
            'hardware-> ${info.androidDeviceInfo.hardware}'); // e.g. "Moto G (4)"
        infos.add(
            'version-> ${info.androidDeviceInfo.version}'); // e.g. "Moto G (4)"
        infos.add('host-> ${info.androidDeviceInfo.host}'); // e.g. "Moto G (4)"
        infos.add(
            'isPhysicalDevice-> ${info.androidDeviceInfo.isPhysicalDevice}'); // e.g. "Moto G (4)"
        infos.add(
            'manufacturer-> ${info.androidDeviceInfo.manufacturer}'); // e.g. "Moto G (4)"
        infos.add(
            'product-> ${info.androidDeviceInfo.product}'); // e.g. "Moto G (4)"
        infos.add('tags-> ${info.androidDeviceInfo.tags}'); // e.g. "Moto G (4)"
        infos.add(
            'supported32BitAbis-> ${info.androidDeviceInfo.supported32BitAbis}'); // e.g. "Moto G (4)"
        infos.add(
            'supported64BitAbis-> ${info.androidDeviceInfo.supported64BitAbis}'); // e.g. "Moto G (4)"
        infos.add(
            'manufacturer-> ${info.androidDeviceInfo.manufacturer}'); // e.g. "Moto G (4)"
        infos.add(
            'fingerprint-> ${info.androidDeviceInfo.fingerprint}'); // e.g. "Moto G (4)"
      }
      if (DeviceUtils.isIos) {
        infos.add("isPhysicalDevice->${info.iosDeviceInfo.isPhysicalDevice}");
        infos.add("isPhysicalDevice->${info.iosDeviceInfo.model}");
        infos.add("isPhysicalDevice->${info.iosDeviceInfo.name}");
        infos
            .add("isPhysicalDevice->${info.iosDeviceInfo.identifierForVendor}");
        infos.add("isPhysicalDevice->${info.iosDeviceInfo.localizedModel}");
        infos.add("isPhysicalDevice->${info.iosDeviceInfo.systemName}");
        infos.add("isPhysicalDevice->${info.iosDeviceInfo.systemVersion}");
        infos.add("isPhysicalDevice->${info.iosDeviceInfo.utsname}");
      }
      setState(() {
        _devInfo='';
        infos.forEach((value) {
          _devInfo = _devInfo + value + "\n";
        });
      });
    });
  }

  getNetInfo() {
    DeviceUtils.checkConnectivity().then((result) {
      List<String> infos = [];
      if (result == ConnectivityResult.mobile) {
        infos.add("I am connected to a mobile network.");
      } else if (result == ConnectivityResult.wifi) {
        infos.add("I am connected to a wifi network.");
      } else {
        infos.add("I am not  connected to a  network.");
      }
      setState(() {
        _netInfo = infos.toString();
      });
    });
  }
}

''';
Map<String,String> sources={
  "sourceDemo01":sourceDemo01,
  "sourceDemo02":sourceDemo02,
  "sourceDemo03":sourceDemo03,
  "sourceDemo04":sourceDemo04,
  "sourceDemo05":sourceDemo05,
  "sourceDemo06":sourceDemo06,
  "sourceDemo07":sourceDemo07,
  "sourceDemo08":sourceDemo08,
  "sourceDemo09":sourceDemo09,
  "sourceDemo10":sourceDemo10,
  "sourceDemo11":sourceDemo11,
  "sourceDemo12":sourceDemo12,
  "sourceDemo13":sourceDemo13,
  "sourceDemo14":sourceDemo14,
  "sourceDemo15":sourceDemo15,
  "sourceDemo16":sourceDemo16,
  "sourceDemo17":sourceDemo17,
  "sourceDemo18":sourceDemo18,
  "sourceDemo19":sourceDemo19,
  "sourceDemo20":sourceDemo20,
  "sourceDemo21":sourceDemo21,
  "sourceDemo22":sourceDemo22,
  "sourceDemo23":sourceDemo23,
  "sourceDemo24":sourceDemo24,
  "sourceDemo25":sourceDemo25,

};
